<?php

	$sRtlAttr = isset($_GET['rtl']) ? ' dir="rtl"': '';
	$sVersion = file_get_contents('.VERSION');
	
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"<?php echo $sRtlAttr; ?>>
	<head>
		<title>Loading ...</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<link type="text/css" rel="stylesheet" href="static/css/main.css" />
	</head>
	<body>
		<div id="loading">Loading ...</div>
		<div id="login-screen" class="hide">
			<form action="index.php" id="login-form">
				<div class="login-form-row">
					<label for="sIncLogin">Login:</label>
					<input type="text" id="sIncLogin" value="" />
				</div>
				<div class="login-form-row">
					<label for="sIncPassword">Password:</label>
					<input type="password" id="sIncPassword" value="" />
				</div>
				<div class="login-form-row">
					<label for="sIncHost">Host:</label>
					<input type="text" id="sIncHost" value="" />
				</div>
				<div class="login-form-row">
					<label for="iIntPort">Port:</label>
					<input type="text" id="iIntPort" value="" />
				</div>
				<div class="login-form-row">
					<input type="submit" value="Login" />
				</div>
				<div class="clear"></div>
			</form>
		</div>
		<div id="mail-screen" class="hide">
			<div class="sub-table">
				<div class="sub-table-row">
					<span id="info"></span>
					<span id="logout-link" style="text-decoration: underline; cursor: pointer;">logout</span>
				</div>
				<div class="sub-table-row">
					<div id="left-pane" class="sub-table-cell">
						<div id="compose">
							<div id="compose-link"><span>compose</span></div>
						</div>
						<div id="search">
							<input type="text" name="search-input" id="search-input" />
							<span class="button">+</span>
						</div>
						<div id="folders"></div>
					</div>
					<div id="right-pane" class="sub-table-cell">
						<div id="tabs-pane"></div>
						<div id="center-pane">
							<div id="list-cache" class=""></div>
							<div id="message-cache" class=""></div>
							<div id="draft-cache" class=""></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
<div id="templates" class="hide"><?php

	$sDir = 'static/templates';
	if (@is_dir($sDir))
	{
		if (false !== ($rDirHandle = @opendir($sDir)))
		{
			while (false !== ($sFile = @readdir($rDirHandle)))
			{
				if ('.html' === substr($sFile, -5))
				{
					echo '<textarea id="template-'.$sFile.'">'.htmlspecialchars(
						preg_replace('/[\s]+/', ' ', file_get_contents($sDir.'/'.$sFile))
					).'</textarea>';
				}
			}
			closedir($rDirHandle);
		}
	}

	function IncludeJs($mFile)
	{
		if (is_array($mFile))
		{
			foreach ($mFile as $sJsItem)
			{
				IncludeJs($sJsItem);
			}
		}
		else if (is_string($mFile))
		{
			echo '<script type="text/javascript" src="static/js/'.$mFile.'"></script>';
		}
	}
?></div><?php

	IncludeJs(array(
		'jquery-1.4.2.min.js', 'jquery.cookie.js', 'jquery.history.js',
		'jquery.autocomplete.js', 'jquery.template.js'));

	IncludeJs(array(
		'functions.js', 'app.js', 'screen-login.js', 'screen-mail.js', 'template-data-builder.js', 'tabs.js', 'prefetch.js'));
	
?><script type="text/javascript">/*<![CDATA[*/$(window).load(function(){window.wm=new WebMail})/* ]]>*/</script>

	</body>
</html><!-- <?php echo $sVersion; ?> -->
